#include "CDate.h"
#include <iostream>
#include <time.h>

using namespace std;

CDate::CDate(void){setToday();}
CDate::CDate(int day,int month,int year) : iDay(day), iMonth(month), iYear(year) {}

void CDate::setToday()
{
time_t t = time(0);
tm lt;
localtime_s(&lt,&t);

setDay(lt.tm_mday);
setMonth(lt.tm_mon+1);
setYear(lt.tm_year+1900);

}

CDate        :: ~CDate(void)			 
{
}
int  CDate   :: getDay()				         
{
	return iDay;
}
int  CDate   :: getMonth()				      
{
	return iMonth;
}
int  CDate   :: getYear()				
{
	return iYear;
}
void CDate   :: setDay(int day)			
{
	if (day>=1 && day<=31)
		iDay = day;
	else
		iDay = 1;
}
void CDate   :: setMonth(int month)			
{
	if (month>=1 && month<=12)
		iMonth = month;
	else
		iMonth = 1;
}
void CDate   :: setYear(int year)			
{
	if (year >= 0)
		iYear = year;
	else
		iYear = 1;
}
void CDate   :: Show(char ch)			             
{
	cout<<getDay()<<ch<<getMonth()<<ch<<getYear()<<endl;
}
